package eerbaar.v2.app.menuMain;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

import eerbaar.v2.app.menu.IMenuItem;
import eerbaar.v2.app.menu.IMenuProvider;

public class MainMenuProvider implements IMenuProvider {

    private final static MainMenuProvider instance = new MainMenuProvider();
    private final static String ID = "main";

    public static MainMenuProvider getInstance() {
        return instance;
    }

    private final JMenu fileMenu = new JMenu();

    public MainMenuProvider() {
        init();
    }

    @Override
    public void addMenuItem(IMenuItem menu) {
        //
        JMenuItem item = new JMenuItem();
        item.addActionListener(new MenuAdaptor(menu));
        item.setText(menu.getText());
        this.fileMenu.add(item);
    }

    @Override
    public String getId() {
        return ID;
    }

    private void init() {
        // JPanel frame = App.instance().getMainWindow().getFrame();
        // JMenuBar bar = new JMenuBar();
        // frame.setJMenuBar(bar);

        // this.fileMenu.setText("Game");
        // bar.add(this.fileMenu);
    }

    @Override
    public void removeMenuItem(IMenuItem menu) {
        throw new java.lang.UnsupportedOperationException();
    }

}
